<?php
/**
 *
 * @author andrew carlson <andrew@acstudiosllc.com>
 * @version 0.0.1
 * @copyright 2012 ACStudios LLC
 * @package default
 */

namespace Encompass\Projects;
use PDO;

/**
 * Projects controller
 *
 * @package default
 * @author  andrew carlson <andrew@acstudiosllc.com>
 */
class projectsController extends \Encompass\Core\coreController {

	function __construct() {
		$action = \Encompass\Utilities\utilities::actionRoute();
		$this->$action();
	}

	/**
	 * display the page template
	 */
	function grid() {
		// get data
		$pm_model = new \Encompass\Projects\projectsModel;
		$projects = $pm_model -> view();

		// pass data to view
		$pm_view = new \Encompass\Projects\projectsView;
		$pm_view -> display();

		// we're done here
		exit ;
	}

	/**
	 * get list of projects by user id
	 */
	function listByUser() {
		$pm_model = new \Encompass\Projects\projectsModel;
		$projects = $pm_model -> projectsByUser();

		$pm_view = new \Encompass\Projects\projectsView;
		$pm_view->dhtmlxJson($projects);
	}

	function getAllProjects() {
		Header('Content-type: text/xml');
		$pm_model = new \Encompass\Projects\projectsModel;
		$projects = $pm_model -> view();

		// pass data to view
		$pm_view = new \Encompass\Projects\projectsView;
		$pm_view -> convertToXml($projects);
	}
}
